<?php

namespace app\admin\model\partner\level;

use think\Lang;
use think\Model;


class Setting extends Model
{

    

    

    // 表名
    protected $name = 'partner_level_setting';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'level_text'
    ];
    

    
    public function getLevelList()
    {
        Lang::load(APP_PATH . '/admin/lang/zh-cn/partner/level/setting.php');
        return ['1' => __('Level 1'), '2' => __('Level 2'), '3' => __('Level 3'), '4' => __('Level 4'), '5' => __('Level 5')];
    }


    public function getLevelTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['level']) ? $data['level'] : '');
        $list = $this->getLevelList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function upgraderule()
    {
        return $this->hasMany('app\admin\\model\\partner\\upgrade\\Setting', 'level_id', 'id');
    }




}
